package com.example.tests;

import java.util.Collections;
import java.util.List;

import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;

public class ContactCreationTests extends TestBase{


  @Test
  public void testNonEmptyContactCreation() throws Exception {
	app.getNavigationHelper().openMainPage(); 
	
	//save old state 
	List<ContactData> oldList = app.getContactHelper().getContacts();
	
	 // actions 
	app.getContactHelper().initContactCreation();
	ContactData contact = new ContactData();
	contact.name = "Svetlana";
	contact.surname = "Sechenikova";
	contact.address = "Matrosova st.";
	contact.homePhone = "333333";
	contact.mobilePhone = "444444";
	contact.workPhone = "555555";
	contact.email = "sveta@mail.ru";
	contact.email2 = "sveta2@mail.ru";
	contact.birthDay = "18";
	contact.birthMonth = "April";
	contact.birthYear = "1988";
	contact.contactGroup = "Rob";
	
	app.getContactHelper().fillContactFields(contact);
    app.getContactHelper().submitContactCeation();
    app.getContactHelper().returnToHomePage();
    
    //save new state
    List<ContactData> newList = app.getContactHelper().getContacts();
    
    //compare states
    oldList.add(contact);
    Collections.sort(oldList);
    assertEquals(newList, oldList);
  }
  
}
